<%@ Page Language="C#" MasterPageFile="~/default.master" Title="Image View" %>
<%@ import Namespace="Memories" %>
<%@ import Namespace="Memories.Entities" %>
<script runat="server">


    string path = "";
    Settings settings;
    File file;
    File prevfile;
    File nextfile;
    

	void Page_Load(Object sender, EventArgs e) {

        settings = (Settings)Context.Items["Settings"];
        path = (string)Context.Items["Path"];

        file = MemoriesDB.GetFile(settings, path);

        Folder folder = file.Parent;
        
        int pos = -1;

        for (pos = 0; pos < folder.Files.Count; pos++)
        {
            if (file.Name == folder.Files[pos].Name)
            {
                break;
            }
        }

        if (pos > 0) prevfile = folder.Files[pos - 1];
        if (pos < folder.Files.Count - 1) nextfile = folder.Files[pos + 1];

        this.Title = settings.Title + " : " + folder.Name + " : " + file.Name;
   }
    
</script>
<asp:Content ID="Content2" ContentPlaceHolderID="PageHeader" runat="server">
    <h2><%=file.Name %></h2>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentWrapper" runat="server">
    <table width="100%" cellpadding="0" cellspacing="0">
        <tr >
            <td id="centerpane">
                <div id="MainImageHolder">
                    <p><b><%=file.Title %></b></p>
                    <img src="<%=settings.UrlFormatter.GetImageUrl(file.RelativePath,500) %>" />
                    <p><%=file.Comment %></p>
                </div>
                
            </td>
            <td id="rightpane" valign="top">
                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                    <%if (prevfile!= null) {%>
                    <td class="imagecell">
                        <a href="<%=settings.UrlFormatter.GetImageViewUrl(prevfile.RelativePath) %>">
                            <img alt="<%=prevfile.Title %>" src="<%=settings.UrlFormatter.GetImageUrl(prevfile.RelativePath,80) %>" />
                        </a>
                        <br />
                        <a href="<%=settings.UrlFormatter.GetImageViewUrl(prevfile.RelativePath) %>">
                            <%=GetGlobalResourceObject("Localization", "prev") %>
                        </a>
                    </td>
                    <%} %>
                    <%if (nextfile != null)
                      {%>
                    <td class="imagecell">
                        <a href="<%=settings.UrlFormatter.GetImageViewUrl(nextfile.RelativePath) %>">
                            <img alt="<%=nextfile.Title %>" src="<%=settings.UrlFormatter.GetImageUrl(nextfile.RelativePath,80) %>" />
                        </a>
                        <br />
                        <a href="<%=settings.UrlFormatter.GetImageViewUrl(nextfile.RelativePath) %>">
                            <%=GetGlobalResourceObject("Localization", "next") %>
                        </a>
                    </td>
                    <%} %>
                    </tr>
                </table>
                <div class="fullimagelink">
                    <a href="<%=settings.UrlFormatter.GetImageUrl(file.RelativePath,0) %>" target="_blank"><%=GetGlobalResourceObject("Localization", "Download_full_image") %></a>
                </div>
            </td>
        </tr>
    </table>
</asp:Content>
